package com.stf.base;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.stf.dialoglibrary.DialogManager;
import com.stf.dialoglibrary.DiaogUtil;
import com.stf.dialoglibrary.PopWindowUtils;

public class MainActivity extends AppCompatActivity {

    private EditText editText;
    private TextView pwdTv;
    private LinearLayout lay;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        editText = findViewById(R.id.mark_edit);
        pwdTv = findViewById(R.id.pwd_tv);
        lay = findViewById(R.id.lay);
        String ymd = new CalendarUtil().getYMD3();
        int num = Integer.parseInt(ymd.substring(ymd.length() - 1, ymd.length())) + 3;
        String pwd = ymd + ymd.substring(ymd.length() - 2, ymd.length()) + num;
        editText.setText(pwd);
    }

    public void onBtnClick(View view) {
        String msg = editText.getText().toString();
        if (TextUtils.isEmpty(msg)) {
            Toast.makeText(this, "请输入密码", Toast.LENGTH_SHORT).show();
            return;
        }
        String base64 = Base64Utils.makeUidToBase64(msg);
        pwdTv.setText(base64);
        Log.i("hx", "--pwdTv-->" + base64);
    }

    public void onBtnClick2(View view) {
        String ymd = new CalendarUtil().getYMD3();
        int num = Integer.parseInt(ymd.substring(ymd.length() - 1, ymd.length())) + 3;
        String pwd = ymd + ymd.substring(ymd.length() - 2, ymd.length()) + num;
        editText.setText(pwd);
    }

    public void onDialogClick(View view) {
        DialogManager.getInstance().setVisCanTv(false).setIsShowToast(false).showDialog(this, lay);
    }
}